//
//  LoadingUI.m
//  Bespoke
//
//  Created by Cheng on 13/1/3.
//
//

#import "LoadingUI.h"

#define LOADINGVIEW_TAG 10000000
#define LOADINGIMAGE_TAG 20000000

@implementation LoadingUI

+(NSString *)IconPressed:(NSString *)Source {
    
    NSString *SourcePath;
    
    if ([Source isEqualToString:@"Twitter"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"Twitter_icon_logo" ofType:@"png"];
    else if ([Source isEqualToString:@"Facebook"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"Facebook_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"Tumblr"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"Tumblr_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"Instagram"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"Instagram_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"GoogleReader"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"GoogleReader_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"DesignSponge"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"DesignSponge_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"TheBump"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"TheBump_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"DailyCandy"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"DailyCandy_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"TheSartorialist"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"TheSartorialist_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"Uncrate"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"Uncrate_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"TheKitchn"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"TheKitchn_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"LottieandDoof"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"LottieandDoof_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"ApartmentTherapy"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"ApartmentTherapy_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"CoolHunting"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"CoolHunting_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"Themarthablog"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"Themarthablog_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"HuffingtonPost"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"HuffingtonPost_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"TinyWrld"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"TinyWrld_icon" ofType:@"png"];
    else if ([Source isEqualToString:@"StyleMePretty"])
        SourcePath = [[NSBundle mainBundle] pathForResource:@"StyleMePretty_icon" ofType:@"png"];
    else
        SourcePath = [[NSBundle mainBundle] pathForResource:@"B_on" ofType:@"png"];
    
    return SourcePath;
}

+ (UIView *)LoadingView:(int)BoundsWidth SetHeight:(int)BoundsHeight {
    
    UIView *Vw_Loading = [[UIView alloc] initWithFrame:CGRectMake(0, 0, BoundsWidth, BoundsHeight)];
    [Vw_Loading setTag:LOADINGVIEW_TAG];
    [Vw_Loading setBackgroundColor:[UIColor blackColor]];
    [Vw_Loading setAlpha:0.5];
    
    return Vw_Loading;
}

+ (UIImageView *)LoadingImage:(int)BoundsWidth SetHeight:(int)BoundsHeight {
    
    UIImageView *IVw_Loading = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 75, 75)];
    IVw_Loading.center = CGPointMake(BoundsWidth/2, BoundsHeight/2);
    IVw_Loading.animationImages = [NSArray arrayWithObjects:
                                   [UIImage imageNamed:@"LoadingAnim 3_00000.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00001.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00002.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00003.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00004.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00005.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00006.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00007.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00008.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00009.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00010.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00011.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00012.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00013.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00014.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00015.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00016.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00017.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00018.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00019.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00020.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00021.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00022.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00023.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00024.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00025.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00026.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00027.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00028.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00029.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00030.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00031.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00032.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00033.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00034.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00035.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00036.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00037.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00038.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00039.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00040.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00041.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00042.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00043.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00044.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00045.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00046.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00047.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00048.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00049.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00050.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00051.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00052.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00053.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00054.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00055.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00056.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00057.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00058.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00059.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00060.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00061.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00062.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00063.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00064.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00065.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00066.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00067.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00068.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00069.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00070.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00071.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00072.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00073.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00074.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00075.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00076.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00077.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00078.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00079.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00080.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00081.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00082.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00083.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00084.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00085.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00086.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00087.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00088.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00089.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00090.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00091.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00092.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00093.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00094.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00095.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00096.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00097.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00098.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_00099.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000100.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000101.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000102.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000103.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000104.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000105.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000106.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000107.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000108.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000109.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000110.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000111.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000112.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000113.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000114.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000115.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000116.png"],
                                   [UIImage imageNamed:@"LoadingAnim 3_000117.png"], nil];
    
    IVw_Loading.animationDuration = 2;
    IVw_Loading.animationRepeatCount = 0;
    
    [IVw_Loading startAnimating];
    [IVw_Loading setTag:LOADINGIMAGE_TAG];
    
    return IVw_Loading;
}

@end
